﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Infragistics.Win.Misc;

namespace DefWinMsgTest
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private static int PointX { get; set; } = 0;
        private static int PointY { get; set; } = 0;

        protected override void WndProc(ref Message m)
        {
            if (m.Msg == 331)
            {
                PointX += 2;
                PointY += 2;
                UltraButton btn = new UltraButton();
                var btnLocation = btn.Location;
                btnLocation.Y = PointY;
                btnLocation.X = PointX;
                this.Controls.Add(btn);
            }
            else
            {
                base.WndProc(ref m);
            }
        }

        protected override void DefWndProc(ref Message m)
        {
            if (m.Msg == 333)
            {
                PointX += 2;
                PointY += 2;
                UltraButton btn = new UltraButton {Location = new Point(PointX, PointY)};
                this.Controls.Add(btn);
            }
            else
            {
                base.DefWndProc(ref m);
            }
        }
    }
}
